{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "阶乘和为: 2561327494111820313\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "def factorial_sum(n):\n",
    "    total = 0\n",
    "    for i in range(1, n + 1):\n",
    "        total += math.factorial(i)\n",
    "    return total\n",
    "\n",
    "# 输入一个数字\n",
    "n = int(input(\"请输入一个正整数: \"))\n",
    "result = factorial_sum(n)\n",
    "print(f\"阶乘和为: {result}\")\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
